<?
require_once($_SERVER['DOCUMENT_ROOT']."/common.inc");
require_once("leaguebase.func.inc");

define ('LEAGUE_LOGO', '../uploads/league_logo/');

//获取指定社团类别
$scid = isset($_GET['scid'])?intval($_GET['schid']):0;

$CurrSelMenu=4;
$Dbh = MyDB();
islogin(); //判断用户是否登录
$UsrInfo = unserialize($Session_UsrRealInfo); //获取登录用户信息

//require_once("../header.inc.php");
//require_once("member_left.inc.php");

//返回社团分类信息数组
$LeagueClass = GetLeagueClass();
//foreach($LeagueClass as $lc)echo $lc[scid];

if($scid)$where = "scid = $scid";
else
	$where = "1";
$sql = "select count(sid) from league_info where $where and isdel = 0";
//echo $sql;
$num = $Dbh->getOne($sql);
echo $num;

//每页社团显示数
$PageStep = 20;
$Pagetotal = ceil($num/$PageStep);
$Request_p = isset($Request_p)?intval($Request_p):1;

//获取社团的会员数
//$League_Num = GetLeagueMemberNum(,'sid');
$sql = "select sid, count(sid) num from usr_league group by sid";
$result = $Dbh->query($sql);
while($row = $result->fetchRow())$League_Num[$row['sid']] = $row['num'];	

$sql = "select a.*, b.cname as schname from league_info a, other_school b where $where and a.schid = b.schid and isdel = 0 order by sid desc limit ".(($Request_p-1)*$PageStep).",".$PageStep;
echo $sql;
$result = $Dbh->query($sql);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../styles/basic.css" />
<link rel="stylesheet" type="text/css" href="../styles/main.css" />
<link rel="stylesheet" type="text/css" href="../styles/yulijiu.css" />
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="styles/ie.css" />
<![endif]-->
<script src='../js/domtab.js'></script>
<script src='../js/DOMhelp.js'></script>
<script src='../js/pagination.js'></script>
</head>
<body>
<div id='wrapper'>
	<h1>韭园<span>菊</span>色</h1>
    <p id="log"><a href="../signin.html">注册</a><a href="login.php">logout</a></p>
	<div class='content'>
		<div class="main">
        	<h2>全部社团</h2>
			<div class="clubList clubActivities">
				<h3>社团列表</h3>
				<div class="pagination">
 	<?

	$TurnPageList = TrunPages($Pagetotal,$Request_p);
	$split_str = "";
	if(count($TurnPageList['List'])>2){
		if(!empty($TurnPageList['First'])) echo "<a href=\"".$TurnPageList['First']."\" target=\"_self\">首页</a>";
		if(!empty($TurnPageList['Last'])||count($TurnPageList['List'])>2) $split_str ='&nbsp; &nbsp;|&nbsp; &nbsp;';
		
			foreach($TurnPageList['List'] as $k=>$v){
				
				echo $split_str ."<a href=\"$v\" target=\"_self\">$k</a>";
				$split_str ='&nbsp; &nbsp;|&nbsp; &nbsp;';
			}
		if(!empty($TurnPageList['Last']))echo $split_str."<a href=\"".$TurnPageList['Last']."\" target=\"_self\">末页</a>";
	}
	if(count($TurnPageList['List'])<=2){
		if(!empty($TurnPageList['Up'])) echo "<a href=\"".$TurnPageList['Up']."\" target=\"_self\">上页</a>";
		if(!empty($TurnPageList['Next']))echo $split_str."<a href=\"".$TurnPageList['Next']."\" target=\"_self\">下页</a>";	
	}
	?>
                </div>
				<ol>
<?
while($rows = $result->fetchRow()){
	echo '<li>';
	echo '<dl>';
	echo '<dt><a href="#">'.$rows['cname'].'<img alt="'.GetLeaguelogopath($rows[regtime]).'" src="'.GetLeaguelogopath($rows[regtime]).' " /></a></dt>';
	echo '<dd>学校: '.$rows['schname'].'</dd>';
	echo '<dd>地址: '.$rows['address'].'</dd>';
	$leaguemembernum = isset($League_Num['$row[sid]'])?intval($League_Num['$row[sid]']):0;
	echo '<dd>社团成员人数: '.$leaguemembernum.'</dd>';
	echo '<dd class="actions clearFix"><a href="#" class="join">申请加入</a> <a href="#" class="interested">我感兴趣</a></dd>';
	echo '</dl></li>';
}
?>					
<!--
                    <li>
                        <dl>
                            <dt><a href="#">八卦团<img src="../images/activity2.jpg" /></a></dt>
                            <dd>当前活动:<a href="#">曾哥的明天</a></dd>
                            <dd>学校:北京大学</dd>
                            <dd>地址:西环广场</dd>
                            <dd>社团成员人数: 55</dd>
                            <dd class="actions clearFix"><a href="#" class="join">申请加入</a> <a href="#" class="interested">我感兴趣</a></dd>
                        </dl>
                    </li>
                    <li>
                    	<dl>
                        	<dt><a href="#">八卦团<img src="../images/activity2.jpg" /></a></dt>
                            <dd>当前活动:<a href="#">曾哥的明天</a></dd>
                            <dd>学校:北京大学</dd>
                            <dd>地址:西环广场</dd>
                            <dd>社团成员人数: 55</dd>
                            <dd class="actions clearFix"><a href="#" class="join">申请加入</a> <a href="#" class="interested">我感兴趣</a></dd>
                        </dl>
					</li>
                    <li>
                    	<dl>
                        	<dt><a href="#">八卦团<img src="../images/activity2.jpg" /></a></dt>
                            <dd>当前活动:<a href="#">曾哥的明天</a></dd>
                            <dd>学校:北京大学</dd>
                            <dd>地址:西环广场</dd>
                            <dd>社团成员人数: 55</dd>
                            <dd class="actions clearFix"><a href="#" class="join">申请加入</a> <a href="#" class="interested">我感兴趣</a></dd>
                        </dl>
					</li>
                    <li>
                    	<dl>
                        	<dt><a href="#">八卦团<img src="../images/activity2.jpg" /></a></dt>
                            <dd>当前活动:<a href="#">曾哥的明天</a></dd>
                            <dd>学校:北京大学</dd>
                            <dd>地址:西环广场</dd>
                            <dd>社团成员人数: 55</dd>
                            <dd class="actions clearFix"><a href="#" class="join">申请加入</a> <a href="#" class="interested">我感兴趣</a></dd>
                        </dl>
					</li>
                    <li>
                    	<dl>
                        	<dt><a href="#">八卦团<img src="../images/activity2.jpg" /></a></dt>
                            <dd>当前活动:<a href="#">曾哥的明天</a></dd>
                            <dd>学校:北京大学</dd>
                            <dd>地址:西环广场</dd>
                            <dd>社团成员人数: 55</dd>
                            <dd class="actions clearFix"><a href="#" class="join">申请加入</a> <a href="#" class="interested">我感兴趣</a></dd>
                        </dl>
					</li>
                    <li>
                    	<dl>
                        	<dt><a href="#">八卦团<img src="../images/activity2.jpg" /></a></dt>
                            <dd>当前活动:<a href="#">曾哥的明天</a></dd>
                            <dd>学校:北京大学</dd>
                            <dd>地址:西环广场</dd>
                            <dd>社团成员人数: 55</dd>
                            <dd class="actions clearFix"><a href="#" class="join">申请加入</a> <a href="#" class="interested">我感兴趣</a></dd>
                        </dl>
					</li>
                    <li>
                    	<dl>
                        	<dt><a href="#">八卦团<img src="../images/activity2.jpg" /></a></dt>
                            <dd>当前活动:<a href="#">曾哥的明天</a></dd>
                            <dd>学校:北京大学</dd>
                            <dd>地址:西环广场</dd>
                            <dd>社团成员人数: 55</dd>
                            <dd class="actions clearFix"><a href="#" class="join">申请加入</a> <a href="#" class="interested">我感兴趣</a></dd>
                        </dl>
					</li>
                    <li>
                    	<dl>
                        	<dt><a href="#">八卦团<img src="../images/activity2.jpg" /></a></dt>
                            <dd>当前活动:<a href="#">曾哥的明天</a></dd>
                            <dd>学校:北京大学</dd>
                            <dd>地址:西环广场</dd>
                            <dd>社团成员人数: 55</dd>
                            <dd class="actions clearFix"><a href="#" class="join">申请加入</a> <a href="#" class="interested">我感兴趣</a></dd>
                        </dl>
					</li>
-->					
            	</ol>
			</div>
			<div class="pagination">
	<?

	$TurnPageList = TrunPages($Pagetotal,$Request_p);
	$split_str = "";
	if(count($TurnPageList['List'])>2){
		if(!empty($TurnPageList['First'])) echo "<a href=\"".$TurnPageList['First']."\" target=\"_self\">首页</a>";
		if(!empty($TurnPageList['Last'])||count($TurnPageList['List'])>2) $split_str ='&nbsp; &nbsp;|&nbsp; &nbsp;';
		
			foreach($TurnPageList['List'] as $k=>$v){
				
				echo $split_str ."<a href=\"$v\" target=\"_self\">$k</a>";
				$split_str ='&nbsp; &nbsp;|&nbsp; &nbsp;';
			}
		if(!empty($TurnPageList['Last']))echo $split_str."<a href=\"".$TurnPageList['Last']."\" target=\"_self\">末页</a>";
	}
	if(count($TurnPageList['List'])<=2){
		if(!empty($TurnPageList['Up'])) echo "<a href=\"".$TurnPageList['Up']."\" target=\"_self\">上页</a>";
		if(!empty($TurnPageList['Next']))echo $split_str."<a href=\"".$TurnPageList['Next']."\" target=\"_self\">下页</a>";	
	}
	?>				
            </div>
		</div>
        <div class="side">
        	<div class="navigateClub">
                <h3><a href="">返回社团首页</a></h3>
                <ul>
<?
foreach($LeagueClass as $lc){
	echo '<li><a href="moreleaguelist.php?scid='.$lc[scid].'">'.$lc['fname'].'</a><li>';
}
?>                	
<!--                	
                    <li><a href="">全部（222）</a></li>
                    <li><a href="">体育运动（122）</a></li>
                    <li><a href="">音乐演出（82）</a></li>
                    <li><a href="">名师讲演（60）</a></li>
-->                    
                </ul>
            </div>
		</div>
	</div>
	<ul id="nav">
		<li><a href="../index.html">首页</a></li>
		<li><a href="../associator/index.html">个人首页</a></li>
		<li><a href="">好友</a></li>
		<li><a href="">通知</a></li>
		<li><a href="">个人设置</a></li>
		<li><a href="">搜索</a></li>
    	<li class='last'><a href="">日志</a></li>	
	</ul>
	
	<div id="footer">
		<ul>
			<li class="noBd"><a href="">Home</a></li>
			<li><a href="">注册</a></li>
			<li><a href="">登陆</a></li>
			<li><a href="">href3</a></li>
			<li><a href="">href3</a></li>
			<li><a href="">href3</a></li>
			<li><a href="">href3</a></li>			
		</ul>
        <p>All rights deserves &copy; <span class="cap">社团</p>
    </div>
</div>

</body>
</html>